#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;
int len(int n)
{
	int ret = 0;
	if (n <= 0)
	{
		n = -n;
		ret++;
	}
	while (n)
	{
		ret++;
		n = n / 10;
	}
	return ret;
}
int main()
{
	int t,p=0,ans=0;
	cin >> t;
	while (t--)
	{
		string s;
		cin>>s;
		if (s.size()==1&&(s[0]>='a'&&s[0]<='z'))
		{
			int x, y;
			cin >> x >> y;
			if (s[0] == 'a')
			{
				p = 1;
				ans = len(x) + len(y) + len(x + y) + 2;
				printf("%d+%d=%d\n", x, y, x + y);
				printf("%d\n", ans);
			}
			else if (s[0] == 'b')
			{
				p = 2;
				ans = len(x) + len(y) + len(x - y) + 2;
				printf("%d-%d=%d\n", x, y, x - y); 
				printf("%d\n", ans);
			}
			else if (s[0] == 'c')
			{
				p = 3;
				ans = len(x) + len(y) + len(x * y) + 2;
				printf("%d*%d=%d\n", x, y, x * y);
				printf("%d\n", ans);
			}
		}
		else
		{
			int x=0,y;
			cin >> y;
			int n = s.size();
			int i = 0;
			while (n)
			{
				x = x * 10 + (s[i] - '0');
				i++;
				n--;
			}
			if (p == 1)
			{
				ans = len(x) + len(y) + len(x + y)+2;
				printf("%d+%d=%d\n", x, y, x + y);
				printf("%d\n", ans);
			}
			else if (p == 2)
			{
				ans = len(x) + len(y) + len(x - y) + 2;
				printf("%d-%d=%d\n", x, y, x - y);
				printf("%d\n", ans);
			}
			else if (p == 3)
			{
				ans = len(x) + len(y) + len(x * y) + 2;
				printf("%d*%d=%d\n", x, y, x * y);
				printf("%d\n", ans);
			}
		}
	}
	return 0;
}